package show.lmm.demo.springboot_aot.core;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import show.lmm.demo.springboot_aot.view.response.BaseResponse;

/**
 * 全局异常捕获器
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = Exception.class)
    public BaseResponse<Boolean> exceptionHandler(Exception e) {
        log.error("global error", e);
        return new BaseResponse<>(500, e.getMessage());
    }
}
